<template>
    <view class="content">
        <u-navbar :background="background" title="我的" title-color="#fff" :border-bottom="false" :immersive="true"
            :is-back="false" back-icon-color="#fff">
            <view class="u-p-l-20" @click="back">
                <u-icon name="arrow-left" color="#fff" size="36"></u-icon>
            </view>
        </u-navbar>
        <image src="../../static/image/s_img_10.png" class="s-img-10" :style="{top: statusBar + 42 + 'px'}"></image>
        
        <view class="wrapper" :style="{marginTop: statusBar + 42 + 'px'}">
            <view class="info">
                <image :src="info.service_img" class="avatar"></image>
                <view class="u-flex-1">
                    <view class="name">{{info.name}}</view>
                    <view class="tel">
                        <image src="../../static/icon/s_tel.png" class="s-tel"></image>
                        <view>{{info.mobile}}</view>
                    </view>
                </view>
            </view>
            
            <view class="top-nav">
                <view class="item" @click="$gTo(`/serve/pages/info/info`)">
                    <image src="../../static/image/s_img_01.png" class="s-img-01"></image>
                    <view>个人资料</view>
                </view>
                <view class="item" @click="$gTo(`/serve/pages/share/share`)">
                    <image src="../../static/image/s_img_02.png" class="s-img-01"></image>
                    <view>推荐分享</view>
                </view>
                <view class="item" @click="$gTo(`/serve/pages/balance/balance`)">
                    <image src="../../static/image/s_img_03.png" class="s-img-01"></image>
                    <view>我的余额</view>
                </view>
                <view class="item" @click="$gTo(`/serve/pages/my-friends/my-friends`)">
                    <image src="../../static/image/s_img_04.png" class="s-img-01"></image>
                    <view>我的社群</view>
                </view>
            </view>
            <!-- 服务报销、我的服务 -->
            <view class="cen-nav">
                <image src="../../static/image/s_img_05.png" class="s-img-05"
                    @click="$gTo(`/serve/pages/fw-bx/fw-bx`)"></image>
                <image src="../../static/image/s_img_06.png" class="s-img-05"
                    @click="$gTo(`/serve/pages/my-serve/my-serve`)"></image>
            </view>
            
            <view class="top-nav">
                <view class="item" @click="$gTo(`/serve/pages/rate/rate`)">
                    <image src="../../static/icon/s_icon_01.png" class="s-icon-01"></image>
                    <view>我的评鉴</view>
                </view>
                <view class="item" @click="$gTo(`/serve/pages/news/news?selfId=${info.id}`)">
                    <image src="../../static/icon/s_icon_02.png" class="s-icon-01"></image>
                    <view>我的消息</view>
                </view>
                <view class="item" @click="$gTo(`/serve/pages/set/set`)">
                    <image src="../../static/icon/s_icon_04.png" class="s-icon-01"></image>
                    <view>陪伴时间</view>
                </view>
                <view class="item" @click="KFshow = true">
                    <image src="../../static/icon/s_icon_03.png" class="s-icon-01"></image>
                    <view>求助电话</view>
                </view>
            </view>
        </view>
        
        <!-- 客服中心 -->
        <u-mask :show="KFshow" mode="center" border-radius="15">
            <view class="popup">
                <view class="win-box2">
                    <view class="pop-up">
                        <view>求助电话</view>
                        <image :src="IMAGEURL + 'static/image/img_09.png'"></image>
                    </view>
                    <view class="pop-call">
                        <view>
                            <view class="school">热线电话</view>
                            <view class="u-font-34 text-bold">{{ service.resort_phone }}</view>
                        </view>
                        <image :src="IMAGEURL + 'static/image/img_tel.png'" @click="$call(service.resort_phone)"></image>
                    </view>
                    <image @click="KFshow = false" class="pop-del" :src="IMAGEURL + 'static/icon/close_02.png'"></image>
                </view>
            </view>
        </u-mask>
        
        <view class="tabbar">
            <view class="tab" @click="change(1)">
                <image src="../../static/icon/s_tab_02.png" class="s-tab-01" v-if="tab == 1"></image>
                <image src="../../static/icon/s_tab_01.png" class="s-tab-01" v-else></image>
                <view :class="{tabActive : tab == 1}">首页</view>
            </view>
            <view class="tab" @click="change(2)">
                <image src="../../static/icon/s_tab_04.png" class="s-tab-01" v-if="tab == 2"></image>
                <image src="../../static/icon/s_tab_03.png" class="s-tab-01" v-else></image>
                <view :class="{tabActive : tab == 2}">实时</view>
            </view>
            <view class="tab" @click="change(3)">
                <image src="../../static/icon/s_tab_06.png" class="s-tab-01" v-if="tab == 3"></image>
                <image src="../../static/icon/s_tab_05.png" class="s-tab-01" v-else></image>
                <view :class="{tabActive : tab == 3}">社群</view>
            </view>
            <view class="tab" @click="change(4)">
                <image src="../../static/icon/s_tab_08.png" class="s-tab-01" v-if="tab == 4"></image>
                <image src="../../static/icon/s_tab_07.png" class="s-tab-01" v-else></image>
                <view :class="{tabActive : tab == 4}">我的</view>
            </view>
        </view>
    </view>
</template>

<script>
    import { IMAGEURL } from '@/static/js/common.js';
    
    export default {
        data() {
            return {
                IMAGEURL,
                statusBar: 0,
                background: { backgroundColor: 'rgba(242,151,0,1)' },
                tab: 4, //1首页 2实时 3社群 4我的
                KFshow: false,
                info: {},
                service: {},//客服
                
            };
        },
        onLoad() {
            let _this = this;
            //状态栏高度
            uni.getSystemInfo({
            	success: function(res) {
            		_this.statusBar = res.statusBarHeight;
            	}
            });
            
        },
        onShow() {
            this.getInfo()
            this.getService()
        },
        methods: {
            
            getInfo() {
            	this.$ajax('user_detail', {
            		user_token: this.$getSync('userToken'),
            	}).then(ret => {
            		if (ret.success == 1000) {
                        this.info = ret.detail
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
            
            // 获取客服电话
            getService() {
            	this.$ajax('service_center', {
            		
            	}).then(ret => {
            		this.service = ret.detail
            	});
            },
            
            // 切换服务人员底部导航
            change(num) {
                if (num == 1) {
                    this.$cTo(`/serve/pages/tab/home`)
                } else if (num == 2) {
                    this.$cTo(`/serve/pages/tab/realtime`)
                } else if (num == 3) {
                    this.$cTo(`/serve/pages/tab/friends`)
                } else if (num == 4) {
                    return
                    // this.$cTo(`/serve/pages/tab/us`)
                }
            },
            
            back() {
                uni.switchTab({
                    url: '/pages/tabbar/mine'
                })
            },
            
            onPageScroll: function(e) {
            	//nvue暂不支持滚动监听，可用bindingx代替
            	// console.log("滚动距离为：" + e.scrollTop);
            	let a = e.scrollTop * 0.05;
            	if (a > 1) {
            		a = 1;
            	}
                this.background.backgroundColor = 'rgba(242,151,0,1)';
            	// if (e.scrollTop == 0) {
            	// 	this.background.backgroundColor = 'rgba(0,0,0,0)';
            	// } else {
            	// 	this.background.backgroundColor = 'rgba(0,0,0,' + a + ')';
            	// }
            },
        }
    };
</script>

<style lang="scss">
    
    page{
        background-color: #f7f8fb;
    }
    .content{
        padding-bottom: 120rpx;
    }
    .tabbar{
        width: 100vw;
        height: 115rpx;
        background-color: #fff;
        border-top: 2rpx solid #e6e6e6;
        display: flex;
        justify-content: space-around;
        align-items: center;
        position: fixed;
        bottom: 0;
        left: 0;
        z-index: 999;
    }
    .tab{
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        font-size: 24rpx;
    }
    .s-tab-01{
        width: 50rpx;
        height: 50rpx;
    }
    .tabActive{
        color: #f29700;
    }
    
    .s-img-10{
        width: 750rpx;
        height: 310rpx;
        position: absolute;
        left: 0;
        z-index: -1;
    }
    .wrapper{
        padding: 30rpx;
    }
    .info{
        display: flex;
        justify-content: flex-start;
        align-items: center;
        padding-bottom: 35rpx;
    }
    .avatar{
        width: 109rpx;
        height: 109rpx;
        border: 2rpx solid #fff;
        border-radius: 50%;
        margin-right: 25rpx;
    }
    .name{
        font-size: 35rpx;
        color: #fff;
    }
    .tel{
        padding-top: 10rpx;
        font-size: 30rpx;
        color: #fff;
        display: flex;
        justify-content: flex-start;
        align-items: center;
    }
    .s-tel{
        width: 20rpx;
        height: 26rpx;
        margin-right: 10rpx;
    }
    
    
    .top-nav{
        padding: 40rpx 0;
        background-color: #fff;
        border-radius: 15rpx;
        margin-bottom: 20rpx;
        display: flex;
        justify-content: space-around;
        align-items: center;
    }
    .item{
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        font-size: 24rpx;
    }
    .s-img-01{
        width: 96rpx;
        height: 96rpx;
        margin-bottom: 15rpx;
    }
    .s-icon-01{
        width: 48rpx;
        height: 48rpx;
        margin-bottom: 12rpx;
    }
    .cen-nav{
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20rpx;
    }
    .s-img-05{
        width: 339rpx;
        height: 174rpx;
    }
    
    
    // 客服弹窗
    .popup {
        width: 100vw;
        height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
    }
    .win-box2 {
        width: 77vw;
        background-color: #ffffff;
        border-radius: 20upx;
        position: relative;
        background: #fff;
        border-radius: 10rpx;
        padding-bottom: 20rpx;
    }
    .pop-up {
        width: 77vw;
        height: 166upx;
        background: linear-gradient(to right, #f29801, #ffcb74);
        color: #fff;
        border-top-left-radius: 10upx;
        border-top-right-radius: 10upx;
        display: flex;
        justify-content: space-between;
        align-items: center;
        box-sizing: border-box;
        padding-left: 55upx;
        padding-right: 24upx;
        position: relative;
    }
    .school{
        font-size: 22rpx;
        padding-top: 5rpx;
    }
    .pop-up > view {
        font-size: 40upx;
        color: #ffffff;
    }
    .pop-up > image {
        font-size: 40upx;
        color: #ffffff;
        width: 290upx;
        height: 207upx;
        position: absolute;
        bottom: 0;
        right: 24upx;
    }
    .pop-call {
        width: 66vw;
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        padding: 30upx 0;
        margin: 0 auto;
        font-weight: bold;
    
        image {
            width: 155rpx;
            height: 56rpx;
        }
    }
    .pop-del {
        width: 8vw;
        height: 8vw;
        position: absolute;
        left: 35vw;
        bottom: -100upx;
    }

</style>
